﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace PostgreSQL.ModelsQi
{
    public partial class TemperatureMatrixContext : DbContext
    {
        public TemperatureMatrixContext()
        {
        }

        public TemperatureMatrixContext(DbContextOptions<TemperatureMatrixContext> options)
            : base(options)
        {
        }

        public virtual DbSet<ErrorLog> ErrorLogs { get; set; }
        public virtual DbSet<TestDatum> TestData { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=TemperatureMatrix;Persist Security Info=True;User ID=qi;Password=123456;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS");

            modelBuilder.Entity<ErrorLog>(entity =>
            {
                entity.ToTable("ErrorLog");

                entity.Property(e => e.Id).HasColumnName("ID");

                entity.Property(e => e.Msg).HasColumnType("text");

                entity.Property(e => e.OmegaTime).HasColumnType("datetime");
            });

            modelBuilder.Entity<TestDatum>(entity =>
            {
                entity.Property(e => e.Id).HasColumnName("ID");

                entity.Property(e => e.ChaXunYongShiMs).HasColumnName("ChaXunYongShi_ms");

                entity.Property(e => e.CreatedOn).HasColumnType("datetime");

                entity.Property(e => e.DataIr).HasColumnType("text");

                entity.Property(e => e.OmegaTime).HasColumnType("datetime");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
